<template>
  <div v-loading="$store.state.pageLoading" class="app-container dashboard-editor-container" element-loading-text="数据加载中...">
    <div class="chart-wrapper" style="margin-bottom:32px;">
      <p class="totla-num" style="text-align:right;padding-right:30px">
        <el-tag type="success">合计:{{ $store.state.ticketCount.num }}张票</el-tag>
      </p>
      <bar-chart v-if=" $store.state.showTicketCountChart" :chart-data="$store.state.lineChartData" />
    </div>
    <el-table :data="$store.state.ticketCount.list" border fit highlight-current-row>
      <el-table-column label="票种" align="center">
        <template slot-scope="scope">{{ scope.row.typeName }}</template>
      </el-table-column>
      <el-table-column label="人数" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.number || 0 }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { ticketCount } from "@/api/ticketing";
import BarChart from "../../components/BarChart";

export default {
  components: { BarChart },
  created() {
    this.initFun();
  },
  methods: {
    async initFun() {
      this.$store.state.pageLoading = true;
      let res = await ticketCount();
      this.$store.state.pageLoading = false;
    }
  }
};
</script>
